import java.util.Stack;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-04-12
 * Time:10:40
 */
public class Text2 {
    public static void main(String[] args) {
        String s="(]";
        Stack<Character> fw=new Stack<>();
        for(int i=0;i<s.length();i++)
        {
            char ch=s.charAt(i);
            if(ch=='('||ch=='['||ch=='{')
            {
                fw.push(ch);
            }
            else{
                if(fw.empty())
                {
                    System.out.println("1");
                   // return false;
                }
                else{
                    char tem=fw.pop();
                    if(tem=='('&&ch==')'||tem=='{'&&ch=='}'||tem=='['&&ch==']');
                    else
                    {
                        System.out.println("0");
                        break;
                    }
                }
            }
        }
        if(!fw.empty())
        {

            System.out.println(0);//return false;
        }
        else System.out.println(1);
        //return true;
    }
}

